package com.bawan.utils;

import java.util.List;

/**
 * Desc:  ${TODO}
 * Author: zhengcongchun
 * CreateTime: 2014-04-17 17:25
 * LastModifyTime: 2014-04-17 17:25
 * FinalModifier: zhengcongchun
 * Version: 1.0
 */
public class SortUtil {
    /**
     * 选择排序
     * @param data
     */
    public void selectSort(int[] data) {
        int i, j, temp;
        for (i = 0; i < data.length; i ++) {
            for (j = i + 1; j < data.length; j ++) {
                if (data[i] > data[j]) {
                    temp = data[i];
                    data[i] = data[j];
                    data[j] = temp;
                }
            }
        }
    }

    /**
     * 冒泡排序
     * @param data
     */
    public void bubbleSort(int[] data) {
        int i, j, temp;
        for (i = data.length - 1; i > 0; --i) {
            for (j = 0; j < i; j ++) {
                if (data[j] > data[j + 1]) {
                    temp = data[j];
                    data[j] = data[j + 1];
                    data[j + 1] = temp;
                }
            }
        }
    }

    public void quickSort(int[] data, int left, int right) {
        int i, j;
        int first, temp;
        i = left;
        j = right;
        first = data[left];
        while(true) {
            while ((++i) < right - 1 && data[i] < first) {

            }
        }
    }
}
